<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>职工档案管理系统</title>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/font-awesome.min.css">
  <link rel="stylesheet" href="css/ionicons.min.css">
  <link rel="stylesheet" href="css/skin-blue.min.css">

  <!-- jQuery 3 -->
  <script src="js/jquery.min.js"></script>
  <!-- Bootstrap 3.3.7 -->
  <script src="js/bootstrap.min.js"></script>
  <!-- AdminLTE App -->
  <script src="js/adminlte.min.js"></script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <div class="content-wrapper">
      <section class="content-header" style="text-align: center">
        <h1>
          欢迎登录职工档案管理系统
        </h1>
      </section>
    <section class="content container-fluid">
	<div class="box box-info">
            <form class="form-horizontal">
              <div class="box-body">
                <div class="form-group">
                  <label class="col-sm-2 control-label">用户名</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="username" name="username" >
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">密码</label>
                  <div class="col-sm-10">
                    <input type="password" class="form-control" id="password" name="password">
                  </div>
                </div>
              </div>
              <!-- /.box-body -->
              <div class="box-footer" style="text-align: center">
                <input type="button" onclick="login()" class="btn btn-info" style="display:inline-block;margin:0 auto" value="登录"/>
                <input type="button" onclick="toReg()" class="btn btn-info" value="注册" style="display:inline-block;margin:0 auto"/>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <script type="text/javascript">
          function toReg(){
        	  window.location.href='regist.html'
          }
          	function login() {
          		var username = $("#username").val();
          		var password = $("#password").val();
          		if(username=='' || password==''){
          			alert("请输入用户名或密码");
          			return;
          		}
       			$.ajax({
       	            url : "users/login",
       	            type : "post",
       	            async : false,
       	            data : {
       	            	"username":username,
       	            	"password":password
       	            	},
       	            cache : false,
       	            dataType : "json",
       	            success : function(json) {
                      var state = json.state;
                      if(state=='6000'){
                        alert(json.message)
                      }
                      if(state=='1'){
                        alert('登录成功')
                        window.location.href="list.html";
                      }
       	            }
       	        });
			}
          </script>
    </section>
  </div>
</div>

</body>
</html>